        <h1>Quản lý danh mục</h1>
               
        <form id="form" action="" method="post">
            <div class="form-group">
                <div class="form-group">
                    <!-- Single button -->
                    <div class="btn-group">
                        <select id="task" name="task" class="form-control">
                            <option>Tác vụ</option>                
                            <option value="delete">Xóa danh mục</option>
                            <option value="deactive">Ẩn danh mục</option>
                            <option value="active">Hiện danh mục</option>
                        </select>
                    </div>
                    <a class="btn btn-primary" href="admin.php?r=categories/insert"><i class="glyphicon glyphicon-plus"></i> Thêm mới</a>
                    <div class="btn-group pull-right">
                        <input id="search" name="search" type="text" value="" class="form-control" placeholder="Tìm kiếm"/>
                    </div>        
                </div>        
            </div>
            
        <table class="table table-bordered " >
            <thead>
                <tr>
                    <td><input id="check_all" type="checkbox" /></td>
                    <td>ID</td>
                    <td>Name</td>
                    <td>Key word</td>
                    <td>Description</td>
                    <td>Position</td>
                    <td>Status</td>
                </tr>            
            </thead>
            <tbody>
                <?php foreach($categories as $categorie) : ?>
                <tr>
                    <td><label class=" checkbox-inline"><input  name="id[]" type="checkbox" value="<?php echo $categorie['id']; ?>" /></label></td>
                    <td><?php echo $categorie['id']; ?></td>
                    <td>
                        <a href="admin.php?r=categories/update&id=<?php echo $categorie['id']; ?>"><?php echo $categorie['name']; ?></a>
                    </td>
                    <td><?php echo $categorie['keywords']; ?></td>
                    <td><?php echo $categorie['description']; ?></td>
                    <td><?php echo $categorie['position']; ?></td>
                    <td><i class="<?php echo $categorie['status'] ? 'glyphicon glyphicon-ok' : 'glyphicon glyphicon-remove' ; ?>" ></i></td>
                    <td><a class="btn btn-warning" href="admin.php?r=categories/update&id=<?php echo $categorie['id']; ?>"><i class="glyphicon glyphicon-list-alt"></i> Sửa</a></a></td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
        
        </form>
        <!---hiển thị phân trang -->
         
        <?php echo $pagination; ?>        

        <script type="text/javascript">
            $(document).ready(function () {
                $('#check_all').change(function(){
                    $('.table input:checkbox').prop('checked', this.checked);
                });
                $('#task').change(function(){
                    var check = true;
                    if ($(this).val()=="delete") {
                        check = confirm('Có chắc bạn muốn xóa?');
                    }
                    if (check) {
                        $('#form').submit();
                    } else {
                        $('#task option:first-child').prop('selected', true);
                    }         
                });
                $('#search').keyup(function(e){
                    if (e.which==13) {
                        $('#form').submit();
                    }                
                });
            });
</script>
